Learn Technologies

Unity Main Menu

In this tutorial, you will learn how make a basic Main Menu:
3 Buttons in order to navigate to Missions, Settings scene and Exit application event.

Create new project:

Create new 3D project called “Main Menu”.
Let’s add a background Canvas.
After that, add 3 buttons inside a background panel:
– Play
– Settings
– Exit

For each button, we need to add the on click event script.
Create a new script attached on Background Panel called “MainMenuButtons.cs”:

using UnityEngine;
using UnityEngine.SceneManagement;

public class MainMenuButtons : MonoBehaviour {

	public void PlayButtonEvent()
    {
        SceneManager.LoadScene("MissionsScene");
    }

    public void SettingsButtonEvent()
    {
        SceneManager.LoadScene("SettingsScene");
    }

    public void ExitButtonEvent()
    {
        Application.Quit();
    }
}

Finally, attach every button with the right method and run the game.

Follow Me For Updates

Subscribe to my YouTube channel or follow me on Twitter or GitHub to be notified when I post new content.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x